#define _GNU_SOURCE
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>


void *first_pthread(void *arg){
    printf("first进程开始执行%d=arg=%s\n",gettid(),(char *)arg);

    static int val = 27;
    return &val;
}

void *second_pthread(void *arg){
    printf("second进程开始执行%d-arg=%d\n",gettid(),*(int *)arg);
    return "GEM";
}

int main(int argc, char const *argv[])
{
    printf("主进程开始%d\n",gettid());
    pthread_t pt1,pt2;
    pthread_create(&pt1,NULL,first_pthread,"hello LJT");
    int val = 4;
    pthread_create(&pt2,NULL,second_pthread,&val);

    int *pt1_val;
    char *pt2_val;
    pthread_join(pt1,(void **)&pt1_val);
    pthread_join(pt2,(void **)&pt2_val);
    printf("first1=%d\n",*pt1_val);
    printf("first2=%s\n",pt2_val);

    printf("主进程结束%d\n",gettid());


    return 0;
}
